import { validAmount } from "@/utils/ElFormValid";

class RevampFormItem {
  id?: number;
  user_id?: number;
  category?: string[];
  goods_detail?: string;
  money?: string;
  check_money?: string;

  // 生成一个空对象
  static empty(): RevampFormItem {
    return {
      id: undefined,
      user_id: undefined,
      category: [],
      goods_detail: "",
      money: "",
      check_money: "",
    };
  }
}

const revampFormRules = {
  category: [
    {
      required: true,
      message: "请选择改造项目",
      trigger: "blur",
    },
  ],
  goods_detail: [
    {
      required: true,
      message: "请输入改造项目",
      trigger: "blur",
    },
  ],
  money: [
    {
      required: true,
      message: "请输入改造金额",
      trigger: "blur",
    },
    { required: true, validator: validAmount, trigger: "blur", message: "请输入正确的金额" },
  ],
  check_money: [
    {
      required: true,
      message: "请输入可补贴金额",
      trigger: "blur",
    },
    { required: true, validator: validAmount, trigger: "blur", message: "请输入正确的金额" },
  ],
};

export { RevampFormItem, revampFormRules };
